#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define LF(x) fixed << setprecision(x);
typedef pair<int, int> pii;
#define endl "\n"

void solve() {
    string s;
    cin >> s;

    vector<pii>v;

    int n = s.size();
    for (int i = 0; i < n; i++) {
        v.push_back({ s[i] - 'a' + 1, i + 1 });
    }

    int ans = 0;
    vector<int> res;

    int a = v[0].first;
    int b = v[n - 1].first;

    int k = 0;

    bool flag = a <= b ? true : false;

    if (a > b) swap(a, b);
    if (!flag) {
        sort(v.begin(), v.end(), [&](pii& X, pii& Y) {
            if (X.first < Y.first || X.first > Y.first) {
                return X.first < Y.first;
            }
            else if (X.first == Y.first) {
                return X.second > Y.second;
            }
            });
    }
    else sort(v.begin(), v.end());
    for (auto [x, y] : v) {
        if (x >= a && x <= b) {
            ans++;
            res.push_back(y);
        }
    }

    if (!flag) {
        reverse(res.begin(), res.end());
    }
    cout << abs(a - b) << ' ' << ans << endl;
    for (int i = 0; i < res.size(); i++) {
        cout << res[i] << " \n"[i == res.size() - 1];
    }

}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}